//
//  MapDetailedViewController.m
//  ASHT_IOS
//
//  Created by 宋安安 on 14-4-30.
//  Copyright (c) 2014年 宋安安. All rights reserved.
//

#import "MapDetailedViewController.h"

@interface MapDetailedViewController ()

@end

@implementation MapDetailedViewController
@synthesize  dic_mapRegionPhoneBeanList,dic_mapPointBeanList;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    if(self.bool_ann)
    {
        lab_address.text=[dic_mapPointBeanList objectForKey:@"address"];
        lab_title.text=[dic_mapPointBeanList objectForKey:@"title"];
        lab_mapRegionInfo.text=[dic_mapPointBeanList objectForKey:@"content"];
        NSArray *arr=[dic_mapPointBeanList objectForKey:@"imageUrlList"];
        for (int i=0; i<arr.count; i++) {
            NSString *url=[arr objectAtIndex:i];
            NSString *str_url=[NSString stringWithFormat:SERVER_BASICE_URL@"phone!getImg.action?imgUrl=%@",url];
            NSURL *imageurl=[[NSURL alloc] initWithString:str_url];
            EGOImageView *egoimageview=[[EGOImageView alloc] init];
            egoimageview.frame=CGRectMake(10+(3210*i), 0, 300, 286);
            [egoimageview setImageURL:imageurl];
            if (egoimageview.image==nil) {
                egoimageview.image=[UIImage imageNamed:@"l_title.png"];
            }
            [scrollview addSubview:egoimageview];
            scrollview.contentSize=CGSizeMake( 320*(i+1),
                                              286);
            [scrollview setPagingEnabled:YES];
        }
        
        pageControl.backgroundColor = [UIColor clearColor];
        pageControl.pageIndicatorTintColor=[UIColor grayColor];
        pageControl.currentPageIndicatorTintColor=[UIColor blackColor];
        pageControl.numberOfPages = arr.count;
        pageControl.currentPage = 0;
        [self.view_Content addSubview:pageControl];
    }
    else
    {
        lab_address.text=[dic_mapPointBeanList objectForKey:@"address"];
        lab_mapRegionInfo.text=[dic_mapRegionPhoneBeanList objectForKey:@"mapRegionInfo"];
        lab_title.text=[dic_mapRegionPhoneBeanList objectForKey:@"mapRegionTitle"];
        NSArray *arr=[dic_mapPointBeanList objectForKey:@"imageUrlList"];
        for (int i=0; i<arr.count; i++) {
            NSString *url=[arr objectAtIndex:i];
            NSString *str_url=[NSString stringWithFormat:SERVER_BASICE_URL@"phone!getImg.action?imgUrl=%@",url];
            NSURL *imageurl=[[NSURL alloc] initWithString:str_url];
            EGOImageView *egoimageview=[[EGOImageView alloc] init];
            egoimageview.frame=CGRectMake(10+(3210*i), 0, 300, 286);
            [egoimageview setImageURL:imageurl];
            if (egoimageview.image==nil) {
                egoimageview.image=[UIImage imageNamed:@"l_title.png"];
            }
            [scrollview addSubview:egoimageview];
            scrollview.contentSize=CGSizeMake( 320*(i+1),
                                              286);
            [scrollview setPagingEnabled:YES];
        }
        
        pageControl.backgroundColor = [UIColor clearColor];
        pageControl.pageIndicatorTintColor=[UIColor grayColor];
        pageControl.currentPageIndicatorTintColor=[UIColor blackColor];
        pageControl.numberOfPages = arr.count;
        pageControl.currentPage = 0;
        [self.view_Content addSubview:pageControl];

    }
    
    // Do any additional setup after loading the view from its nib.
}
-(IBAction)pageChange:(id)sender
{
    [scrollview setContentOffset:CGPointMake(pageControl.currentPage * 320,0) animated:YES];
    [pageControl setCurrentPage:pageControl.currentPage];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    int page = 0;
    page= scrollView.contentOffset.x/320;
    [pageControl setCurrentPage:page];
    [pageControl updateCurrentPageDisplay];
}
@end
